﻿<UserControl x:Class="ViewTester"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="600">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition  />
            <ColumnDefinition MinWidth="200" Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
            <ComboBox Name="cbo" MinWidth="150" DisplayMemberPath="Name" ItemsSource="{Binding ModelColumns}"/>
            <Button  MinWidth="100" Content="Ajouter" Command="{Binding AddColCommand}" CommandParameter="{Binding ElementName=cbo, Path=SelectedItem}"/>
            <Button  MinWidth="100" Content="Supprimer" />
            <Button  MinWidth="100" Content="Reset" Command="{Binding ResetCommand}" />
            <Button Content="Calculer" Command="{Binding ComputeCommand}" />
        </StackPanel>
        <DataGrid
            Grid.Row="1" ColumnWidth="*"
            IsReadOnly="False" 
            AutoGenerateColumns="True"
            ItemsSource="{Binding Table}"
            CanUserDeleteRows="True"
            CanUserAddRows="True" Grid.ColumnSpan="1">
            
        </DataGrid>
        <GridSplitter HorizontalAlignment="Left" Grid.Column="1" Grid.Row="1" Width="5"/>
        <ListBox Grid.Column="1" Grid.Row="1" SelectedItem="{Binding SelectedParam}" ItemsSource="{Binding Params}" Margin="5,0,0,0" HorizontalContentAlignment="Stretch">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalAlignment" Value="Stretch" />
                </Style>
            </ListBox.ItemContainerStyle>
                <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch"  >
                        <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="5" />
                    </Grid.ColumnDefinitions>

                    <Expander HorizontalAlignment="Stretch"  Header="{Binding Title}" HorizontalContentAlignment="Left">
                       <Grid HorizontalAlignment="Stretch" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="5" />
                            </Grid.ColumnDefinitions>
                        <DataGrid HorizontalAlignment="Stretch"  ColumnWidth="100"
                            IsReadOnly="False" 
                            AutoGenerateColumns="True"
                            ItemsSource="{Binding Table}"    
                            CanUserDeleteRows="False"
                            CanUserAddRows="False"  />
                        </Grid>
                    </Expander>
                        </Grid >
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
